package com.szd.qiongyou20.home.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.szd.qiongyou20.R;
import com.szd.qiongyou20.home.bean.CityData;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by SZD on 2016/12/23.
 */

public class RecyclerView_City_Play_Adapetr extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context mContext;
    private List<CityData.DataBean.RecommendDiscountBean> mList;

    public RecyclerView_City_Play_Adapetr(Context context, List<CityData.DataBean.RecommendDiscountBean> list) {
        mContext = context;
        mList = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_city_playing, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ViewHolder){
            String photo = mList.get(position).getPhoto();
            String price = mList.get(position).getPrice();
            String name = mList.get(position).getName();

            Glide.with(mContext).load(photo).into(((ViewHolder) holder).mImageViewCityPlay);
            ((ViewHolder) holder).mTextViewCityPlayPrice.setText(price+"元起");
            ((ViewHolder) holder).mTextViewCityPlayDetails.setText(name);
        }
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.imageView_city_play)
        ImageView mImageViewCityPlay;
        @Bind(R.id.textView_city_play_price)
        TextView mTextViewCityPlayPrice;
        @Bind(R.id.textView_city_play_details)
        TextView mTextViewCityPlayDetails;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
